package com.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.demo.entity.KeShiBiao;
import com.demo.entity.PingJia;
import com.demo.entity.YiSheng;
import com.demo.entity.YiShengPaiBan;
import com.demo.entity.YuYueJiuZheng;
import com.demo.entity.YuYueTime;
import com.demo.service.JiuzhengService;
import com.demo.service.PaibanService;

import net.sf.json.JSONObject;

@RestController
@RequestMapping("/jiuzzheng")
@CrossOrigin
public class JiuZhengController {
	
	@Autowired
	private JiuzhengService jiuzhengService;
	
	@Autowired
	private PaibanService pbPaibanService;
	
	@RequestMapping("/selectAll")
	public List<YiSheng> selectAll(){
    	return jiuzhengService.selectAll();
    }
	
	//科室查医生
	@RequestMapping("/findyishengBykeshi")
	public List<YiSheng> findyishengBykeshi(String keshi){
		return jiuzhengService.findyishengBykeshi(keshi);
	}
	
	//科室查医生
	@RequestMapping("/findAllKeshi")
	public List<KeShiBiao> findAllKeshi(){
		return jiuzhengService.selectAllk();
				
	}
	
	//科室查医生
	@RequestMapping("/findKeshiByid")
	public KeShiBiao findKeshiByid(int id){
		return jiuzhengService.selectByPrimaryKeyk(id);
				
	}
	
	//科室查医生
		@RequestMapping("/getKeshiName")
		public String getKeshiName(String keshi){
			System.out.println("keshi");
			if(keshi!=""&&keshi!=null) {
				keshi  = jiuzhengService.selectByPrimaryKeyk(Integer.valueOf(keshi)).getKeshi();
			}
			System.out.println(keshi+"aa");
			return keshi;
		}
	
	@RequestMapping("/findavaliablePanban")
	public List<YiShengPaiBan>  findavaliablePanban(String keshi){
		return pbPaibanService.findavaliablePanban(keshi);
	}
	
	@RequestMapping("/findADateList")
	public List<String> findADateList(String keshi){
		return pbPaibanService.findADateList(keshi);
	}
	
	@RequestMapping("/findADateListByyIsheng")
	public List<String> findADateListByyIsheng(String keshi,String yisheng){
		return pbPaibanService.findADateListByyIsheng(keshi,yisheng);
	}
	
	@RequestMapping("/findAYishengBuKeshi")   
	public List<YiSheng> findAYishengBuKeshi(String keshi){
		return pbPaibanService.findAYishengBuKeshi(keshi);
	}
	
	@RequestMapping("/chooseDoctorByDateKeAKeshi")   
	public List<YiSheng> chooseDoctorByDateKeAKeshi(String keshi,String date){
		return pbPaibanService.chooseDoctorByDateKeAKeshi(keshi,date);
	}
	
	@RequestMapping("/quguahao")   
	public String quguahao(String yonghu,String yisheng,String riqi,String shijian,int feiyongflag,int okflag,String zhengzhuang) {
		return jiuzhengService.quguahao(yonghu, yisheng, riqi, shijian, feiyongflag, okflag, zhengzhuang);
	}
	
	@RequestMapping("/seemyYuYue") 
	public List<YuYueJiuZheng> myYuYue(String yonghu){
		return jiuzhengService.myYuYue(yonghu);
	}
	
	@RequestMapping("/tuihao") 
	public int tuihao(int id){
		return jiuzhengService.tuihao(id);
	}
	
	@RequestMapping("/topingjia1") 
	public YuYueJiuZheng topingjia1(int id){
		return jiuzhengService.topingjia1(id);
	}

	@RequestMapping("/addpingjia") 
	public int addpingjia(String jiuzhengbianhao,String score,String jianyi){
		return jiuzhengService.addpingjia(jiuzhengbianhao, score, jianyi);
	}
	
	@RequestMapping("/checkpingjiaexist") 
	public PingJia checkpingjiaexist(String jiuzhengbianhao){
		System.out.println(jiuzhengService.checkpingjiaexist(jiuzhengbianhao));
		return jiuzhengService.checkpingjiaexist(jiuzhengbianhao);
	}
	
	
	@RequestMapping("/findAYuyuelTimes")
	List<YuYueTime>  findAYuyuelTimes(String yisheng,String date){
		System.out.println(jiuzhengService.findAlTimes(yisheng,date).toString());
		return jiuzhengService.findAlTimes(yisheng,date);
	}
}
